home *** CD-ROM | disk | FTP | other *** search
- .TOPIC:
- Number and Storage Handling
-
- VBBS 6.12 Documentation -- 10-A-1
-
-
- ╔════════════════════════════════════════════════════════════════╗
- ║ CHAPTER TEN ANNEX A NUMBER AND STRING HANDLING ║
- ╚════════════════════════════════════════════════════════════════╝
-
-
- NUMERIC OPERATORS
- ═════════════════
-
- VSCRIPT supports the following mathematical operators:
-
- + Addition - Subtraction
- * Multiplication / Division
- ^ Exponentiation
-
- All math commands in the script language are performed from
- left-to-right. Parentheses can NOT be used in a formula, so
- any math that needs to be done in a hierarchical format must be
- done over more than one line. Also, remember the restriction
- on 'tokens' - a math symbol counts as a token, so only two math
- operations can be performed on one line.
-
- Example: Results:
- $a= 2 * 2 + 4 => 4 + 4 => 8
- $b = $a + 2 / 5 => 10 / 5 => 2
- $c = $b + 5 - 4 => 7 - 4 => 3
- $d = 4 / $b ^ 3 => 2 * 2 * 2 => 8
-
-
- NUMERIC FUNCTIONS
- ═════════════════
-
- INT 0 -> <variable1> = <value2> INT 0
-
- This function takes the number stored in <value2> and
- rounds down to the next lower whole number. The resulting
- integer is then stored in <variable1>. Remember: negative
- numbers also round down with this function as shown below:
-
- $total = -11.25 INT 0 returns a value of -12, not -11.
-
- SQR 0 -> <variable1> = <value2> SQR 0
-
- This function returns the square root of the absolute
- value of the number stored in <value2>. The result is then
- stored in <variable1>. Note: The absolute value of a number
- equals its positive value, ie absolute of -11 = 11.
-
- RND -> <variable1> = <value1> RND <value2>
-
- This function generates a random number between the two
- <value>'s. If <value1> is smaller than <value2> then the
- result will not include either number. If <value1> is larger
- than <value2> then the result can include either number.
-
-
- VBBS 6.12 Documentation -- 10-A-2
-
-
- Example: Results:
- $a = 4.15 * 4 + .25 => 16.85
- $b = $a INT 0 => 16
- $c = $b SQR 0 => 4
- $d = $a INT 0 SQR 0 => 4
- $e = $b RND $c => a random number from 4 to 16
- $f = $c RND $b => a random number from 5 to 15
-
-
- STRING OPERATORS
- ════════════════
-
- & -> <variable1> = <token3> & <token5> & <token7>
-
- This allows you to link together many variables and strings
- to print as a single variable, effectively adding many tokens
- together. ex: $Junk = "This is" & " one big " & "statement!"
-
-
- STRING FUNCTIONS
- ════════════════
-
- In addition to the '&' operators there are some functions
- for use with strings and variables that store strings.
-
- ASC 0 -> <variable1> = <string2> ASC 0
-
- This function finds the ASCII code of the first character
- in <string2> and stores it in <variable1>.
-
- CHR 0 -> <variable1> = <value2> CHR 0
-
- This function takes <value2> and places the character with
- the matching ASCII code into <variable1>.
-
- LEN 0 -> <variable1> = <string2> LEN 0
-
- This function returns the number of characters within
- <string2> and places the result in <variable1>.
-
- UPPER 0 -> <variable1> = <string2> UPPER 0
-
- This function returns the upper case equivalent of what is
- in <string2>. It only changes the lower case letters, leaving
- all numbers and symbols as they are in the original <string2>.
-
- INSTR -> <variable1> = <string2> INSTR <string3>
-
- This function scans <string2> to see if <string3> exists
- within it. It returns a 0 to <variable1) if it is not found,
- otherwise it returns the position of <string3>.
-
-
- VBBS 6.12 Documentation -- 10-A-3
-
-
- MID -> <variable1> = <string2> MID <value3>
- LEFT -> <variable1> = <string2> LEFT <value3>
-
- These functions return portions of a string. MID starts
- at the character <value3> and returns the rest of the string.
- LEFT starts at the left-most character and returns a number
- of characters equal to <value3>.
-
- Example: Results:
- $a = "aBc2" & "05 D" & "e╫Fg" => "aBc205 De╫Fg"
- $b = $a MID 10 => ╫Fg
- $c = $b ASC 0 => 215 - the ASCII code for ╫
- $d = $a LEFT 6 MID 4 => 205
- $e = $d CHR 0 => ═ - the ASCII 205 character
- $f = $a INSTR "205" => 4 - the 205 is in the string
- and the 2 is located in
- the 4th position.
- $g = $a LEN 0 => 12
- $h = $a UPPER 0 => "ABC205 DE╫FG"
-
- Note: The quotes in the strings are not an actual part of the
- strings. They are there only to denote the beginning
- and end of a single token.
-
-
- STRING ALTERATIONS
- ══════════════════
-
- There are a few commands that actually allow you to alter
- the format of a variable. All of them use the same syntax and
- are described below.
-
- JC -> JC <variable1> <value2>
- JL -> JL <variable1> <value2>
- JR -> JR <variable1> <value2>
-
- These commands all take what is stored within <variable1>
- and pad it with extra spaces. JC centers the <variable1> in
- a field of <value2> spaces. JL places it along the left margin
- and JR places it on the right margin in a similar field.
-
- Example: Results:
- $size = 14
- $a = "Greed!" => $a now has the value:
- JC $a $size " Greed! "
- $b = "Green!" => $b now has the value:
- JL $b $size "Green! "
- $c = "Groan!" => $c now has the value:
- JR $c $size " Groan!"
-
-
-